package com.taotao.job.core.runresult;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Objects;

/**
 * 运行进度
 *
 * @author fanbeibei
 * @date 2021/4/7 20:26
 */
@Getter
@AllArgsConstructor
public class RunRate implements Serializable {
    /**
     * 在执行器队列中
     */
    public static final String IN_EXECUTOR_QUEUE = "in_executor_queue";
    /**
     * 运行execute方法
     */
    public static final String RUNNING_EXECUTE = "running_execute";
    /**
     * 成功结果
     */
    public static final String SUCCESS_RESULT = "success_result";
    /**
     * 失败结果
     */
    public static final String FAIL_RESULT = "fail_result";
    /**
     * 未知结果
     */
    public static final String UNKNOW_RESULT = "unknow_result";

    /**
     * 未知结果
     */
    public static final String KILLED_RESULT = "killed_result";


    public static boolean isFinalRate(String rate) {
        return Objects.equals(rate, SUCCESS_RESULT) || Objects.equals(rate, FAIL_RESULT) || Objects.equals(rate, KILLED_RESULT);
    }


    private Long runInstanceId;

    private String rate;

}
